package com.check.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

public class YamlConfigLoader {

    public static <T> T load(String file, Class<T> clazz) {
        try {
            ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
            return mapper.readValue(
                    YamlConfigLoader.class.getClassLoader().getResourceAsStream(file),
                    clazz
            );
        } catch (Exception e) {
            throw new RuntimeException("Failed to load yaml: " + file, e);
        }
    }
}
